
{extend name="common@list" /}
{block name="jsset"}

{/block}
{block name="nav"}
	<span class="layui-breadcrumb">
		<a href="">课题管理</a>
		<a><cite>课题册</cite></a>
	</span>
{/block}
{block name="search"}
	<div class="layui-form-item">
      <label for="searchval" class="layui-form-label">
          关键字
      </label>
      <div class="layui-input-block">
          <input type="text" id="searchval" name="searchval"
          autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
	    <label for="xingzhi" class="layui-form-label" style="height: 100%">课题类别</label>
	    <div class="layui-input-block" onclick ="clickSearchButton('#search','mytable')">
	    	{php} $category = getCategory(112);{/php}
	    	{volist name="category" id="vo"}
	    		<input type="checkbox" name="category[]" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
	    	{/volist}
	    </div>
	</div>
	<div class="layui-form-item" style="margin-bottom: 0;">
	    <label for="lxdanweiid" class="layui-form-label" style="height: 100%">立项单位</label>
	    <div class="layui-input-block" onclick ="clickSearchButton('#search','mytable')">
	    	{php} $school = schlist('区级','其它级'); {/php}
	    	{volist name="school" id="vo"}
	    		<input type="checkbox" name="lxdanweiid[]" title="{$vo.jiancheng}" value="{$vo.id}" lay-skin="primary">
	    	{/volist}
	    </div>
	</div>
{/block}
{block name="table"}
	<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="myjs"}
	<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-danger" lay-event="dels">
			<i class="iconfont">&#xe69d;</i> 批量删除
		</button>
		<button class="layui-btn" lay-event="add">
			<i class="iconfont">&#xe6b9;</i> 添加
		</button>
	</div>
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn-xs" lay-event="detail" title="课题列表"><i class="layui-icon">&#xe62d;</i></a>
	<a class="layui-btn-xs" lay-event="more" title="批传"><i class="layui-icon">&#xe67c;</i></a>
	<a class="layui-btn-xs" lay-event="edit" title="编辑"><i class="layui-icon">&#xe642;</i></a>
	<a class="layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon">&#xe640;</i></a>
</script>
<!-- 表格操作 -->
<script>
	// 设置列
  options.cols=[[ //表头
			{type:'checkbox', fixed: 'left'},
			{field: 'title', title: '课题名称',sort: true, minWidth:240},
			{field: 'lxdanweiid', title: '立项单位',sort: true,templet:function(d){
				var str='';
				if(d.kt_lxdanwei)
				{
					str = d.kt_lxdanwei.title;
				}
				return str;
			}},
			{field: "category",title: '课题类别',sort: true,templet:function(d){
				var str='';
				if(d.kt_category)
				{
					str = d.kt_category.title;
				}
				return str;
			}},
			{field: 'lxshijian', title: '立项时间', sort: true},
			{field: 'lxcount', title: '课题数', sort: true},
			{field: 'kt_info_count', title: '已结题', sort: true},
			{field: 'status', title: '状态',templet:'#status', sort: true},
			{field: 'id', title: '操作',toolbar: '#barDemo',minWidth:140}
		]];

  // 提交搜索条件后重载表格
    layui.use(['table','cjgl'],function(){
      var table = layui.table
          cjgl = layui.cjgl;
      //表头工具栏事件
      table.on('toolbar(mytable)', function(obj){
        switch(obj.event){
          case 'dels':
            var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值
            cjgl.delAll(checkStatus,'/kt','mytable');
            break;
          case 'add':
            cjgl.add('添加荣誉册','/kt/create','500','350');
            break;
        };
      });

      //监听行工具条
      table.on('tool(mytable)', function(obj){
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象
        switch(layEvent){
          	case 'detail':// 查看
	          parent.x_admin_add_to_tab(obj.data.title + ' 列表','/ktlist/'+obj.data.id,true);
	          break;
	        case 'del':// 删除
	          cjgl.del(obj,"/kt");
	          break;
	        case 'edit':// 编辑
	          cjgl.add('编辑荣誉册','/kt/'+obj.data.id+'/edit','500','350');
	          break;
	        case 'status':// 状态
	          cjgl.status(obj,"{:url('setstatus')}");
	          break;
	        case 'more':// 状态
	          cjgl.add('批传','/ktinfoaddall/'+obj.data.id,'300','200');
	          break;
        };
      });
    });
</script>
{/block}